import { PromiseData } from '@/@types/request'
import request from '@/utils/request'
import { IBasic, IEventItem, ITargetList } from '../type'
import { IVariableSort, IVariableItem } from '@/@types/common'

// 获取变量信息和基础信息
export const getVariableList = (data: {
  dataId: number
}): Promise<
  PromiseData<{
    dataReportVo: IBasic
    sortPlatformVos: IVariableSort[]
    flag: boolean
    pressureId: string
  }>
> => request.post('/dataReport/getDataTaskDetail', data)

// 获取事件
export const getEventList = (data: { dataId: number }): Promise<PromiseData<IEventItem[]>> =>
  request.post('/dataReport/getInjuryInformation', data)

// 获取计算后的指标
export const getComputedTarget = (data: any): Promise<PromiseData<any>> =>
  request.post('/dataReport/getTargetValue', data)

// 暂存
export const temporaryHandle = (data: any): Promise<PromiseData<{ message: string; success: string }>> =>
  request.post('/dataReport/temporaryStorage', data)

// 获取变量模板
export const getTemplate = (data: { id: string }): any =>
  request.post('/dataReport/getTemplate', data, { responseType: 'blob' })

// 数据填报提交
export const submitHandle = (data: any): Promise<PromiseData<{ message: string; success: string }>> =>
  request.post('/dataReport/submit', data)

// 变量导入
export const importVariable = (data: any): Promise<PromiseData<{ message: string; success: string }>> =>
  request.post('/dataReport/importTemplate', data, { responseType: 'blob' })

// 获取病区组织架构
export const getWard = (data: { hospitalCode: number }): Promise<PromiseData<any>> =>
  request.post('/wardManage/getOrganization', data)

// 事件保存
export const updateOrAdd = (data: any): Promise<PromiseData<any>> =>
  request.post('/dataReport/saveOrUpdateInjuryInformation', data)

// 删除压疮事件
export const deleteEvent = (data: any): Promise<PromiseData<any>> =>
  request.post('/dataReport/deleteInjuryInformation', data)
